# Maintainer: lgehr <lgehr@mailbox.org>
pkgname=minisatip
pkgver=1.3.4
pkgrel=0
pkgdesc="minisatip is an SATIP server for linux using local DVB-S2, DVB-C, DVB-T or ATSC cards"
url="https://minisatip.org"
arch="all"
license="GPL-2.0-or-later"
makedepends="linux-headers openssl-dev libdvbcsa-dev"
install="$pkgname.pre-install"
subpackages="$pkgname-openrc"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/catalinii/minisatip/archive/refs/tags/v$pkgver.tar.gz
	minisatip.initd
	minisatip.confd
	default_document_root.patch
	"

prepare() {
	default_prepare

	# gcc sanitisers don't work on musl
	# #10304
	sed -i 's; -fsanitize=address;;g' tests/Makefile.in
	sed -i 's; -fsanitize=leak;;g' tests/Makefile.in
	sed -i 's; -fsanitize=null;;g' tests/Makefile.in
}

build() {
	# no execinfo.h
	export CFLAGS="$CFLAGS -DNO_BACKTRACE"

	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var
	make
}

check() {
	make -j1 test #parallel execution fails with "text file busy"
}

package() {
	install -Dm755 minisatip "$pkgdir"/usr/bin/minisatip
	mkdir -p "$pkgdir"/usr/share/minisatip/html
	cp -r html "$pkgdir"/usr/share/minisatip

	install -m755 -D "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname
	install -m644 -D "$srcdir"/$pkgname.confd \
		"$pkgdir"/etc/conf.d/$pkgname
}

sha512sums="
12e6d81e1b7c8c0c2206a209aa7f4cf5daabfa1d71f26ce11284f585add5e989685c061f179ada35eaa54e28332a49eef7ef3ace21f9db56d15831a15a33ae52  minisatip-1.3.4.tar.gz
fb0c4125350dbb516fb005ee0246d9219bb7c38a0429fc714bd861990cfa8c13e5e217f5be9cf7216a0f5e912ef1fb6d21e93e98b303286332f66dfee6936460  minisatip.initd
b29b2d4140b2c66431fdf876c0f15f98794be185c786cce7c5c202484e8c73c8b17aa564c37bdca22157fa97ac5598a8c16b58699559b1bd39e4a5c18835bccd  minisatip.confd
f9352ea6973e0314aa5c5bab4ee31dcb2b731fc889115a442d8cf912ae143ed2d04cdacefbebf13c949c0f17c6a800b73d3d0ee804734ba2dfce09783085781a  default_document_root.patch
"
